/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Control;
import Model.*;
import DBLayer.*;
import java.util.ArrayList;
/**
 *
 * @author Radu
 */
public class CtrProduct {
    public CtrProduct(){

    }

    public ArrayList<Product> findAllProducts(){
        DbInterfaceProduct dbProduct = new DbProduct();
        ArrayList allProducts = new ArrayList();
        allProducts = dbProduct.getAllProducts();
        return allProducts;
    }

    public Product getById(String id){
        DbInterfaceProduct dbProduct = new DbProduct();
        return dbProduct.searchById(id);
    }

    public Product getByName(String name){
        DbInterfaceProduct dbProduct = new DbProduct();
        return dbProduct.searchByName(name);
    }

    public ArrayList<Product> getBySupplierId(String id){
        DbInterfaceProduct dbProduct = new DbProduct();
        return dbProduct.searchBySupplierId(id);
    }

    public ArrayList<Product> getByCountry(String country){
        DbInterfaceProduct dbProduct = new DbProduct();
        return dbProduct.searchByCountry(country);
    }

    public int updateProduct(String name, Double purchase_price, Double sale_price, Double rent_price, int min_stock){
        DbInterfaceProduct dbProduct = new DbProduct();
        Product product = new Product();
        product.setName(name);
        product.setPurchasePrice(purchase_price);
        product.setSalesPrice(sale_price);
        product.setRentPrice(rent_price);
        product.setMinStock(min_stock);
        return dbProduct.updateProduct(product);
    }

    public void insertProduct(Product prodObj){
        DbInterfaceProduct dbProd = new DbProduct();
        dbProd.insertProduct(prodObj);
    }

    public void deleteProduct(String id){
        DbInterfaceProduct dbProd = new DbProduct();
        dbProd.deleteProduct(id);
    }

}
